package com.epb.eventpcb.common;

import lombok.Data;

@Data
public class ServiceResult<T> {

    T data;
    int code;
    String desc;

    public ServiceResult(T data, int code, String desc) {
        this.data = data;
        this.code = code;
        this.desc = desc;
    }
    public ServiceResult(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static <T> ServiceResult buildSuccess(T data){
        return new ServiceResult(data,StatusEnum.SUCCESS.getStatus(),StatusEnum.SUCCESS.getDescribe());
    }
    public static <T> ServiceResult buildSuccess(T data, int code, String desc){
        return new ServiceResult(data,code,desc);
    }
    public static <T> ServiceResult buildSuccess(int code, String desc){
        return new ServiceResult(code,desc);
    }
    public static <T> ServiceResult buildSuccess(StatusEnum statusEnum){
        return new ServiceResult(statusEnum.getStatus(),statusEnum.getDescribe());
    }

    public static <T> ServiceResult buildFail(int code, String desc){
        return new ServiceResult(code,desc);
    }
    public static <T> ServiceResult buildFail(StatusEnum statusEnum){
        return new ServiceResult(statusEnum.getStatus(),statusEnum.getDescribe());
    }
}
